version: '3.8'

services:
  db:
    container_name: postgres_db
    image: postgres
    environment:
      - POSTGRES_DB=dbname
      - POSTGRES_USER=user
      - POSTGRES_PASSWORD=pass
    ports:
      - 5432:5432
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U user -d dbname"]
      interval: 10s
      timeout: 50s
      retries: 2
      start_period: 10s

  backend:
    container_name: back
    build: ./back
    image: lct_back
    ports:
      - "8000:8000"
    volumes:
      - ./back:/back
    command: sh -c "./wait_and_run.sh"
    depends_on:
      - db

  frontend:
    container_name: front
    build: ./front
    image: lct_front
    ports:
      - "6781:3000"
    volumes:
      - ./front:/front
      - /front/node_modules
    environment:
      NODE_ENV: production
    command: npm start

networks:
  default: